package views.swing;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class CheckTextField extends JPanel{
	private ImageIcon iTacha=new ImageIcon("src/views/swing/resources/tacha16.png");
	private ImageIcon iInterrogacion=new ImageIcon("src/views/swing/resources/interrogacion16.png");
	private ImageIcon iPaloma=new ImageIcon("src/views/swing/resources/paloma16.png");

	private JTextField campo;
	private JLabel etiqueta=new JLabel(new ImagenVacia(16, 16));

	
	public CheckTextField(){
		campo=new JTextField();
		
		inicializar();
	}
	
	public CheckTextField(JTextField campo){
		this.campo=campo;
		
		inicializar();
	}
	
	private void inicializar(){
		etiqueta.setCursor(new Cursor(Cursor.HAND_CURSOR));
		setLayout(new BorderLayout());
		add(campo, BorderLayout.CENTER);
		add(etiqueta, BorderLayout.EAST);
	}
	
	public void campoCorrecto(){
		etiqueta.setIcon(iPaloma);
	}

	public void campoIncorrecto(String cadena){
		etiqueta.setIcon(iTacha);
		etiqueta.setToolTipText(cadena);
	}
	
	public void campoVacio(){
		etiqueta.setIcon(iInterrogacion);
		etiqueta.setToolTipText("Este dato es importante");
	}
		
	public String getText(){
		return campo.getText();
	}
	
	public void setText(String a){
		campo.setText(a);
	}
}